package com.yunlongn.async.log;

import java.io.Serializable;
import java.util.List;

/**
 * 调度日记实体
 *
 * @author yunlongn
 */
public class LogDo implements Serializable {

    /**
     * 任务当前状态
     */
    public enum Stat {
        /**
         * 任务当前状态
         */
        PENDING("pending"),
        SUCCESS("success"),
        FAIL("fail");
        String stat;

        Stat(String stat) {
            this.stat = stat;
        }

        public String getStat() {
            return stat;
        }
    }

    /**
     * 任务唯一标识
     */
    private String id;
    /**
     * 任务名称
     */
    private String taskName;
    /**
     * 参数类型
     */
    private String paramType;
    /**
     * 序列化后的参数
     */
    private String param;
    /**
     * 自由调度周期
     */
    private List<Integer> freePeriods;
    /**
     * 首次提交执行时间
     */
    private String firstSubmitDate;
    /**
     * 已经重试次数
     */
    private Integer retryCnt;
    /**
     * 不能为空，下一次重试调度时间 = 重新提交时间+freePeriods[retryCnt-1]
     */
    private long nextRetryTime;
    /**
     * 状态：pending、success、fail
     *
     * @see Stat
     */
    private String status;
    /**
     * 当前执行action的客户端
     */
    private String client;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public List<Integer> getFreePeriods() {
        return freePeriods;
    }

    public void setFreePeriods(List<Integer> freePeriods) {
        this.freePeriods = freePeriods;
    }

    public String getFirstSubmitDate() {
        return firstSubmitDate;
    }

    public void setFirstSubmitDate(String firstSubmitDate) {
        this.firstSubmitDate = firstSubmitDate;
    }

    public Integer getRetryCnt() {
        return retryCnt;
    }

    public void setRetryCnt(Integer retryCnt) {
        this.retryCnt = retryCnt;
    }

    public String getParam() {
        return param;
    }

    public void setParam(String param) {
        this.param = param;
    }

    public String getParamType() {
        return paramType;
    }

    public void setParamType(String paramType) {
        this.paramType = paramType;
    }

    public String getTaskName() {
        return taskName;
    }

    public void setTaskName(String taskName) {
        this.taskName = taskName;
    }

    public long getNextRetryTime() {
        return nextRetryTime;
    }

    public void setNextRetryTime(long nextRetryTime) {
        this.nextRetryTime = nextRetryTime;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getClient() {
        return client;
    }

    public void setClient(String client) {
        this.client = client;
    }

    @Override
    public String toString() {
        return "LogEntity{" +
                "id='" + id + '\'' +
                ", taskName='" + taskName + '\'' +
                ", paramType='" + paramType + '\'' +
                ", param='" + param + '\'' +
                ", freePeriods=" + freePeriods +
                ", firstSubmitDate='" + firstSubmitDate + '\'' +
                ", retryCnt=" + retryCnt +
                ", nextRetryTime=" + nextRetryTime +
                ", status='" + status + '\'' +
                ", client='" + client + '\'' +
                '}';
    }

}
